﻿define(['util', 'ajax'], function (util, ajax) {
    "use strict";

    var exports = {},
         ViewModel;    

    ViewModel = function (model) {
        var data = model.detail;
        var self = this;        
        var canvas = document.getElementById("imgCanvas");
        util.image.drawImage(canvas, util.image.checkOrDefault(data.imageData));
        
        self.id = ko.observable(data.id);
        self.tagId = ko.observable(data.tagId);
        self.name = ko.observable(data.name);
        self.code = ko.observable(data.code);
        self.description = ko.observable(data.description);
        self.detectedOn = ko.observable(moment.utc(data.detectedOn).format("MM/DD/YYYY hh:mm:ss"));
        self.imageData = ko.observable(data.imageData);                
    };

    exports.exec = function (sectionId, model) {
        var viewModel = new ViewModel(model);
        ko.applyBindings(viewModel, document.getElementById(sectionId));
    };

    return exports;
});